/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.edu.curso.java.VO;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;



@Entity
@Table(name = "disciplina")
public class DisciplinaVO  implements Serializable { 
    
    	private static final long serialVersionUID = -4969328588154523299L;

	@Id
	@GeneratedValue
	private Integer codigo;

	@Column(unique = true)
	private String descricao;
        
    @Column()
	private short cargaHoraria;
        
    	@ManyToMany(cascade = CascadeType.ALL)
        @LazyCollection(LazyCollectionOption.FALSE)
        //@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
    	@JoinTable(name = "professoresdadisciplina", joinColumns = { @JoinColumn(name = "codigo_disciplina", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "codigo_professor", nullable = false, updatable = false) })
    	private List<ProfessorVO> professores;

    	public List<ProfessorVO> getProfessores() {
    		return professores;
    		    		
    	}

    	public void setProfessores(List<ProfessorVO> professores) {
    		this.professores = professores;
    	}
               
	public Integer getCodigo() {
		return codigo;
	}

	public void setCodigo(Integer codigo) {
		this.codigo = codigo;
	}

	public String getDescricao() {
		return descricao;
	}

	public void setDescricao(String descricao) {
		this.descricao = descricao;
	}

        public Short getCargaHoraria() {
		return cargaHoraria;
	}

	public void setCargaHoraria(Short cargaHoraria) {
		this.cargaHoraria = cargaHoraria;
	}
    @Override
    public String toString() {
        return "Disciplina " + this.getCodigo() + " | " + getDescricao();
    }
        
}
